local jw_shizhong = fk.CreateSkill {
    name = "jw_shizhong",
}

Fk:loadTranslationTable {
    ["jw_shizhong"] = "示众",
    [":jw_shizhong"] = "你对其发动过〖身护〗的角色回合开始时，其可以展示你的随机一张“创”，并弃置一张同类型的牌，" ..
        "视为使用此牌，若弃置的牌与展示的“创”牌名相同，此牌额外结算一次(此牌不能指定你为目标且无距离和次数限制)。",

    ["$jw_shizhong1"] = "重整旗鼓，奋兵再战",
    ["$jw_shizhong2"] = "汝等护主公快走，吾还可一战",
}
jw_shizhong:addEffect(fk.TurnStart, {
    mute = true,
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(jw_shizhong.name) and target ~= player and
            table.contains(player:getTableMark("jw_shenhu"), target.id)
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        for _, id in ipairs(room.alive_players) do
            if id.general == "jw__weizhoutai" then
                return room:askToSkillInvoke(target, {
                    skill_name = jw_shizhong.name,
                    prompt = "示众：是否展示" .. id.id .. "一张“创”，并有机会使用此牌"
                })
            end
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local cards = table.filter(player:getCardIds("h"), function(id)
            return Fk:getCardById(id):getMark("@@zhoutai_chuang-inhand") > 0
        end)
        local id = Fk:getCardById(table.random(cards))
        player:showCards(id)
        room:delay(600)
        local card = room:askToDiscard(target, {
            min_num = 1,
            max_num = 1,
            skill_name = jw_shizhong.name,
            pattern = ".|.|.|.|.|" .. id:getTypeString(),
        })
        if #card > 0 then
            if Fk:getCardById(card[1]).trueName == id.trueName then
                room:addPlayerMark(target, "shizhong_jiesuan-phase")
            end
            local use = room:askToUseVirtualCard(target, {
                name = id.name,
                skill_name = jw_shizhong.name,
                prompt = "示众：你可以视为使用" .. id:toLogString(),
                cancelable = true,
                extra_data = {
                    bypass_distances = true,
                    bypass_times = true,
                },
            })
        end
    end,
})

jw_shizhong:addEffect(fk.CardUsing, {
    can_refresh = function(self, event, target, player, data)
        return table.contains(data.card.skillNames, jw_shizhong.name) and player:getMark("shizhong_jiesuan-phase") > 0
    end,
    on_refresh = function(self, event, target, player, data)
        data.additionalEffect = (data.additionalEffect or 0) + 1
    end,
})

jw_shizhong:addEffect("prohibit", {
    is_prohibited = function(self, from, to, card)
        if table.contains(card.skillNames, jw_shizhong.name) then
            return to:hasSkill(jw_shizhong.name)
        end
    end,
})
return jw_shizhong
